--
-- Author: yawei.zhu
-- Date: 2018-11-14 15:32:29
--
-- RoadHeroNoticeView
--
local IconRender = require("app.widget.renders.IconRender")

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.RoadHeroNotice

function ClassRef:init()
	self._ui.Button_quxiao:addClickEventListener(function()
		executeFunc(self._onOperate, "openRoadOfHero")
		executeFunc(self._onCloseView, self)
	end)
end

function ClassRef:updateView(data)
	local str = string.format(L("task_road_desc16"), data.layer, data.index)
	self._ui.tips_1:setString(str)

	local config = GD:getHeroInfoByIndex(data.layer, data.index, UD:getClass())
	-- 显示奖励
	local arrDrops = UD:parseDropStrToBagItem(config.award, true)
	for i, data in ipairs(arrDrops) do
		local icon = self._ui["Panel/icon_"..i]
		local render = IconRender.create(icon)
		render:setData(arrDrops[i])
		render:setTipEnable(true)
	end

	-- 设置文本居中
	self._ui.tips_2:setString(L("task_road_desc7"))
    display.setNodesMiddle(self._ui.Panel, self._ui.tips_img, self._ui.tips_2)
end

return ClassRef
